#ifndef _MOE_REAL_PERTURB_MUTATION
#define _MOE_REAL_PERTURB_MUTATION

#include "engine/Mutation.hh"
#include "problems/RealArraySolution.hh"


class RealPerturbMutation : public Mutation {

public:

    RealPerturbMutation(double probability) : Mutation(probability) {}

    virtual ~RealPerturbMutation() {}

    protected:

    virtual void mutate(Solution *solution){
        RealArraySolution *realSolution = (RealArraySolution *)solution;

        int r = Random::getInstance()->getInt(RealArraySolution::getSize());

        double value = realSolution->get(r);
        double m = 0.0;
        if (value > 0) m = Random::getInstance()->getReal(-1 * value, value);
        else m = Random::getInstance()->getReal(value, -1 * value);

        realSolution->set(r, value*m);
    }

};

#endif
